Skip to content

Fix rule: ember/template-no-invalid-link-text#2637

Merged
NullVoxPopuli merged 3 commits intoember-cli:masterfrom
tcjr:link-text-conditional
Apr 4, 2026
Merged

Fix rule: ember/template-no-invalid-link-text#2637
NullVoxPopuli merged 3 commits intoember-cli:masterfrom
tcjr:link-text-conditional

Conversation

@tcjr
Copy link
Copy Markdown
Contributor

@tcjr tcjr commented Apr 4, 2026

This PR updates the ember/template-no-invalid-link-text rule to work correctly for conditional child content.

For example, the following template is valid, but currently fails lint for having empty link content.

<template>
  <a href="/play">{{#if game.inProgress}}Continue{{else}}Start{{/if}}</a>
</template>

The problem was occurring because the rule did not treat GlimmerBlockStatement nodes (like {{#if condition}}...{{/if}}) inside the link as dynamic content. Instead, it would skip them, effectively seeing the link text as empty when it only contained a block statement.

I updated the getTextContentResult function to flag GlimmerBlockStatement as dynamic, which bypasses the strict empty link check and allows the rule to gracefully ignore dynamic conditional contents.

I added a few additional tests (like the one above) that fail before this fix.

@NullVoxPopuli NullVoxPopuli merged commit d42876e into ember-cli:master Apr 4, 2026
12 checks passed
@github-actions github-actions Bot mentioned this pull request Apr 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants